//
//  FindEntity.m
//  SXH
//
//  Created by 房 国生 on 15/7/9.
//  Copyright (c) 2015年 lyss. All rights reserved.
//

#import "FindEntity.h"
#import "UserEntity.h"
#import "SDWebImageManager.h"
@implementation FindEntity

@synthesize ID;
@synthesize insert_time;
@synthesize content;
@synthesize images;
@synthesize good;
@synthesize commentCount;
@synthesize mutableArrayUser;
@synthesize img_height;
@synthesize img_width;

- (instancetype)initWithAttributes:(NSDictionary *)attributes {
    
    self = [super init];
    if (!self) {
        return nil;
    }
    
    self.ID= [attributes valueForKeyPath:@"id"];
    self.insert_time = [attributes valueForKeyPath:@"insert_time"];
    self.content = [attributes valueForKeyPath:@"content"];
    self.images = [attributes valueForKeyPath:@"images"];
    self.good = [attributes valueForKeyPath:@"good"];
    self.view_count = [attributes valueForKeyPath:@"view_count"];
    self.userid = [attributes valueForKeyPath:@"user_id"];
    self.userAlbum = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"user_album"]];
    self.nickname = [attributes valueForKeyPath:@"nickname"];
    self.commentCount = [attributes valueForKeyPath:@"comment_count"];
    
    NSNumber *good_flag = [attributes valueForKeyPath:@"good_flag"];
    self.goodflag = [NSString stringWithFormat:@"%d", [good_flag intValue]];
    
    self.img_height = [attributes valueForKeyPath:@"img_height"];
    self.img_width = [attributes valueForKeyPath:@"img_width"];
    self.followed = [attributes valueForKeyPath:@"followed"];
    //首页美图进入解析字段
    self.travel_id = [attributes valueForKeyPath:@"travel_id"];
    if ([attributes valueForKeyPath:@"album_thumb"]) {
        self.album_thumb = [NSString stringWithFormat:@"%@/%@", IMAGE_URL, [attributes valueForKeyPath:@"album_thumb"]];
    }
    //
    
    self.images_ = [attributes valueForKeyPath:@"images_"];
    self.img_height_ = [attributes valueForKeyPath:@"img_height_"];
    self.img_width_ = [attributes valueForKeyPath:@"img_width_"];
    
    NSArray *array  = [attributes valueForKeyPath:@"goodRows"];
    mutableArrayUser = [[NSMutableArray alloc] init];
    
    for (NSDictionary* attributes in array) {
        UserEntity *entity = [[UserEntity alloc] init];
        entity = [entity initWithAttributes:attributes];
        [mutableArrayUser addObject:entity];
    }
    return self;
}




@end
